package cn.org.mrliu.code.generator.web.element;

import java.io.Serializable;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

public class FormElement implements Serializable{
	private static final long serialVersionUID = 5455963345956108117L;
	public static final String TEXT = "text";
	public static final String RADIO = "radio";
	public static final String CHECKBOX = "checkbox";
	public static final String FILE = "file";
	public static final String HIDDEN = "hidden";
	public static final String TEXTAREA = "textarea";
	public static final String SELECT = "select";
	protected String id;
	protected String type;
	protected String name;
	protected String className;
	protected String label;
	protected String append;
	protected String html;
	protected boolean required;
	protected String datatype;
	protected String nullmsg;
	protected String errormsg;
	protected boolean ignore;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getClassName() {
		return className;
	}
	public void setClassName(String className) {
		this.className = className;
	}
	public String getLabel() {
		return label;
	}
	public void setLabel(String label) {
		this.label = label;
	}
	public String getAppend() {
		return append;
	}
	public void setAppend(String append) {
		this.append = append;
	}
	public String getHtml() {
		return html;
	}
	public void setHtml(String html) {
		this.html = html;
	}
	public boolean isRequired() {
		return required;
	}
	public void setRequired(boolean required) {
		this.required = required;
	}
	public String getDatatype() {
		return datatype;
	}
	public void setDatatype(String datatype) {
		this.datatype = datatype;
	}
	public String getNullmsg() {
		return nullmsg;
	}
	public void setNullmsg(String nullmsg) {
		this.nullmsg = nullmsg;
	}
	public String getErrormsg() {
		return errormsg;
	}
	public void setErrormsg(String errormsg) {
		this.errormsg = errormsg;
	}
	public boolean isIgnore() {
		return ignore;
	}
	public void setIgnore(boolean ignore) {
		this.ignore = ignore;
	}
	
	public String getDatatypeString() {
		if (datatype!=null) {
			return " datatype=\""+datatype+"\"";
		}
		return "";
	}
	
	public String getNullmsgString() {
		if (nullmsg!=null) {
			return " nullmsg=\""+nullmsg+"\"";
		}
		return "";
	}
	
	public String getErrormsgString() {
		if (errormsg!=null) {
			return " errormsg=\""+errormsg+"\"";
		}
		return "";
	}
	
	public String getIgnoreString() {
		if (ignore) {
			return " ignore=\""+ignore+"\"";
		}
		return "";
	}
	
	public String getTag() {
		return null;
	}
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
	}
}
